/*
 * ClientProtocol.java
 *
 * Created on 09 September 2006, 17:47
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package libjdc.dc.protocol;

import java.text.MessageFormat;

/**
 *
 * @author root
 */
public class ClientProtocol implements Protocol{
    
    /**
     * This is the command sent by a client when there are no free slots available from the uploading user.
     * @url http://dcpp.net/wiki/index.php/%24MaxedOut
     */
    public static final String DC_S_MESSAGE_MAXEDOUT = COMMAND_START_CHAR+"MaxedOut";
    
    /**
     * This command is sent as a response to $Key. It decides which party gets to download.
     *
     *   * <direction> is either "Upload" or "Download", the only reason to say "Upload" would be that your client does not want to download anything from your peer.     
     *   * <number> is a random number, when both clients want to download, the one with the higher number starts first. if the numbers are equal, the connection is closed.
     * @url http://dcpp.net/wiki/index.php/%24Direction
     */ 
    public static final String DC_S_MESSAGE_DIRECTION = COMMAND_START_CHAR+"Direction ";
    
    /**
     *
     *
     * This command is used to request a file from the uploading client.
     *
     * <file> is the full file name and the path to it, as per the source's $SR or FileList.
     * <offset> is the starting point of the download (counted from 1, not from 0) 
     *
     * The $Error with "File Not Found" is sent when the file is not available. NMDC disconnects the user if no directory is provided. (i.e. $Error on "$Get nonexistent_directory\nonexistent_file$1|" and disconnect on "$Get nonexistent_file$1|")
     *
     * When the file is available, the source must respond with $FileLength.
     *
     * The FileList is retrieved with "$Get MyList.DcLst$1|" 
     *
     * @url http://dcpp.net/wiki/index.php/%24Get
     */
    public static final String DC_S_MESSAGE_GET = COMMAND_START_CHAR+"Get ";
    
    /**
     * $FileLength is sent by the uploading client in response to a $Get command. The only content is the size of the requested file in bytes. 
     * @url http://dcpp.net/wiki/index.php/%24FileLength
     */
    public static final String DC_S_MESSAGE_FILELENGTH = COMMAND_START_CHAR+"FileLength ";
    
    
    public static final String DC_S_MESSAGE_SEND = COMMAND_START_CHAR+"Send";
    
    
    public static final String DC_S_MESSAGE_MYNICK = COMMAND_START_CHAR+"MyNick ";
    public static final MessageFormat MYNICK_PARSER = new MessageFormat(DC_S_MESSAGE_MYNICK+"{0}"+COMMAND_END_CHAR);
    
    
    public static final MessageFormat LOCK_PARSER = new MessageFormat(DC_S_MESSAGE_LOCK+"{0} Pk={1}"+COMMAND_END_CHAR);
    public static final MessageFormat DIRECTION_PARSER = new MessageFormat(DC_S_MESSAGE_DIRECTION+"{0} {1}"+COMMAND_END_CHAR);
    public static final MessageFormat SUPPORTS_PARSER = new MessageFormat(DC_S_MESSAGE_SUPPORTS+"{0}"+COMMAND_END_CHAR);
    public static final MessageFormat GET_PARSER = new MessageFormat(DC_S_MESSAGE_GET+"{0}${1}"+COMMAND_END_CHAR);
    public static final MessageFormat FILELENGTH_PARSER = new MessageFormat(DC_S_MESSAGE_FILELENGTH+"{0}"+COMMAND_END_CHAR);
    public static final String SEND_PARSER = DC_S_MESSAGE_SEND+COMMAND_END_CHAR;
    
}
